package com.tiyende.kash.loop.request

/**
 * 网络错误码
 */
object HttpErrorCode {
    const val SUCCESS = 0
    const val TIMEOUT = -1001
    const val CONNECT_FAILED = -1002
    const val NETWORK_UNAVAILABLE = -1003
    const val SSL_ERROR = -1004
    const val DECRYPT_ERROR = -1005
    const val PROCESS_ERROR = -1006
    const val NO_NETWORK = -1007
    const val UNKNOWN_ERROR = -1099

    // HTTP状态码映射
    fun getMessage(code: Int): String {
        return when (code) {
            400 -> "Request parameter error"
            401 -> "Unauthorized, please log in again"
            403 -> "Access is prohibited"
            404 -> "The requested address does not exist"
            408 -> "Request timeout"
            500 -> "Internal server error"
            502 -> "Bad Gateway"
            503 -> "Service unavailable"
            else -> "Network error($code)"
        }
    }
}